package com.pxst.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pxst.merchant.entity.SysMerchantAgentEntity;
import com.pxst.resp.ApiResp;
import com.pxst.service.AgentService;
import com.pxst.tx.demo.mapper.AgentMapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author cheng
 * @version 创建时间：2023年11月16日 上午10:37:25
 *
 */
public class AgentServiceImpl extends ServiceImpl<AgentMapper, SysMerchantAgentEntity> implements AgentService {

    /**
     * 代理查询
     *
     */
   @Autowired
   private AgentMapper agentMapper;

    @Override
    public ApiResp<List<SysMerchantAgentEntity>> getById(Long id) {
        QueryWrapper<SysMerchantAgentEntity> wrapper = new QueryWrapper<>();
        wrapper.eq("id",id);
        List<SysMerchantAgentEntity> list = agentMapper.selectList(wrapper);
        if(list.isEmpty()){
             return ApiResp.sucess("获取总代和下一级代理的信息");
        }else {
            ApiResp.paramError("获取它本身的信息");
        }
       return ApiResp.sucess();
    }

}
